home *** CD-ROM | disk | FTP | other *** search
/ Borland JBuilder 6 / jbuilder6.iso / Documents / JAVA Programming / examples / 09 / SortString.java < prev    next >
Encoding:
Java Source  |  2000-09-08  |  561 b   |  17 lines

  1. class SortString {
  2. static String arr[] = {"Now", "is", "the", "time", "for", "all",    
  3.                        "good", "men", "to", "come", "to", "the",     
  4.                        "aid", "of", "their", "country" };
  5. public static void main(String args[]) { 
  6. for (int j = 0; j < arr.length; j++) {
  7.      for (int i = j + 1; i < arr.length; i++) { 
  8.           if (arr[i].compareTo(arr[j]) < 0) { 
  9.               String t = arr[j];
  10.               arr[j] = arr[i];
  11.               arr[i] = t;
  12.           } 
  13.      }  
  14.      System.out.println(arr[j]);
  15. } }
  16.